#pragma once

#ifndef __CANVAS_REGEX_REGEXRICH_H
#define __CANVAS_REGEX_REGEXRICH_H

#include "..\Objects.h"
#include "..\Collection.h"

#include "RegExAutomation.h"

namespace Canvas
{
	namespace RegExInternal
	{
		class CaptureRecord
		{
		public:
			int capture;
			int start;
			int length;
			bool operator==(const CaptureRecord& record) const;
		};
	}

	template<>
	struct POD<RegExInternal::CaptureRecord>
	{
		static const bool Result = true;
	};

	namespace RegExInternal
	{
		using Collection::List;
		class RichResult
		{
		public:
			int start;
			int length;
			List<CaptureRecord> records;
		};

		class RichInterpreter : public Object
		{
		protected:
			class UserData {
			public:
				bool NeedKeepState;
			};

			Automation::Ref dfa;
			UserData* datas;
		public:
			RichInterpreter(Automation::Ref _dfa);
			~RichInterpreter();

			bool MatchHead(const wchar_t* input, const wchar_t* start, RichResult& result);
			bool Match(const wchar_t* input, const wchar_t* start, RichResult& result);
			const List<WString>& CaptureNames();

		};
	}
}

#endif // !__CANVAS_REGEX_REGEXRICH_H
